package com.tgu.home_action.pojo;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.sql.Timestamp;

@Data
@ApiModel(description = "公告")
public class Notice {
    public interface insert {
    }

    public interface update {
    }

    @ApiModelProperty("ID")
    @NotNull(message = "id不能为空", groups = {update.class})
    private Integer id;
    @ApiModelProperty("发布人")
    private String publisher;
    @ApiModelProperty("发布人ID")
    private Integer publisherId;
    @NotNull(message = "title不能为空", groups = {insert.class})
    @ApiModelProperty("标题")
    private String title;
    @ApiModelProperty("描述")
    private String description;
    @NotNull(message = "content不能为空", groups = {insert.class})
    @ApiModelProperty("内容")
    private String content;
    /**
     * 1为展示，2为不展示
     */
    @ApiModelProperty("是否展示（1为展示，2为不展示）")
    private Short display;
    @ApiModelProperty(value = "时间", dataType = "java.sql.Date")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp time;
    @NotNull(message = "roleId不能为空", groups = {insert.class})
    @Min(value = 1, message = "roleId只能是1或2", groups = {update.class, insert.class})
    @Max(value = 2, message = "roleId只能是1或2", groups = {update.class, insert.class})
    @ApiModelProperty("面向角色")
    private Integer roleId;

    @JsonBackReference("当前页")
    @ApiModelProperty("当前页")
    private Integer pageNo;

    @JsonBackReference("每页条数")
    @ApiModelProperty("每页条数")
    private Integer pageSize;

    @JsonIgnore
    private Integer startSize;
}
